//****************************************Copyright (c)***********************************//
//ԭ�Ӹ����߽�ѧƽ̨��www.yuanzige.com
//����֧�֣�www.openedv.com
//�Ա����̣�http://openedv.taobao.com 
//��ע΢�Ź���ƽ̨΢�źţ�"����ԭ��"�����ѻ�ȡZYNQ & FPGA & STM32 & LINUX���ϡ�
//��Ȩ���У�����ؾ���
//Copyright(C) ����ԭ�� 2018-2028
//All rights reserved
//----------------------------------------------------------------------------------------
// File name:           video_display
// Last modified Date:  2019/7/1 9:30:00
// Last Version:        V1.1
// Descriptions:        ��Ƶ��ʾģ�飬��ʾ����
//----------------------------------------------------------------------------------------
// Created by:          ����ԭ��
// Created date:        2019/7/1 9:30:00
// Version:             V1.0
// Descriptions:        The original version
//
//----------------------------------------------------------------------------------------
//****************************************************************************************//

module  video_display(
    input                pixel_clk,
    input                sys_rst_n,
    
    input        [10:0]  pixel_xpos,  //���ص�������
    input        [10:0]  pixel_ypos,  //���ص�������
    output  reg  [23:0]  pixel_data   //���ص�����
);

//parameter define
parameter  H_DISP = 11'd1280;                       //�ֱ��ʡ�����
parameter  V_DISP = 11'd800;                        //�ֱ��ʡ�����

//1280-1024 = 256
//800-768 = 32

localparam WHITE  = 24'b11111111_11111111_11111111;  //RGB888 ��ɫ
localparam BLACK  = 24'b00000000_00000000_00000000;  //RGB888 ��ɫ
localparam RED    = 24'b11111111_00001100_00000000;  //RGB888 ��ɫ
localparam GREEN  = 24'b00000000_11111111_00000000;  //RGB888 ��ɫ
localparam BLUE   = 24'b00000000_00000000_11111111;  //RGB888 �ɫ

//*****************************************************
//**                    main code
//*****************************************************

wire [10:0] pixel_xpos2 = pixel_xpos - 128;
parameter H_DISP2 = 1024;
always @(posedge pixel_clk ) begin
    if (!sys_rst_n)
        pixel_data <= 16'd0;
    else begin
        if(pixel_ypos < 15)begin
            pixel_data <= WHITE;
        end else if(pixel_ypos == 15) begin
            pixel_data <= GREEN;
        end else if(pixel_ypos > (800 - 16)) begin
            pixel_data <= WHITE;
        end else if(pixel_ypos == (800 - 16)) begin
            pixel_data <= GREEN;
        end else begin
            if(pixel_xpos < 127)begin
                pixel_data <= WHITE;
            end else if(pixel_xpos == 127)begin
                pixel_data <= GREEN;
            end else if(pixel_xpos > (1280-128))begin
                pixel_data <= WHITE;
            end else if(pixel_xpos == (1280-128))begin
                pixel_data <= GREEN;
				end else begin
					if((pixel_xpos2 < (H_DISP2/5)*1))begin 
						 pixel_data <= RED;  
					end else if((pixel_xpos2 >= (H_DISP2/5)*1) && (pixel_xpos2 < (H_DISP2/5)*2))begin 
						 pixel_data <= GREEN;  
					end else if((pixel_xpos2 >= (H_DISP2/5)*2) && (pixel_xpos2 < (H_DISP2/5)*3))begin 
						 pixel_data <= BLACK;  
					end else if((pixel_xpos2 >= (H_DISP2/5)*3) && (pixel_xpos2 < (H_DISP2/5)*4))begin 
						 pixel_data <= WHITE;
					end else begin 
						 pixel_data <= BLUE;
					end 
				end
         end
    end
end

endmodule